/**
 * @(#)HelloWorldClient.java, 2019/1/7
 * <p/>
 * Copyright 2019 Netease, Inc. All rights reserved.
 * NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.chengzhi.netty.grpc;

import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;

import java.util.concurrent.TimeUnit;

/**
 * @author 阮承志(wb.ruanchengzhi @ mesg.corp.netease.com)
 **/
public class HelloWorldClient {
    private static ManagedChannel channel;

    public static void main(String[] args) {
        channel = ManagedChannelBuilder.forAddress("127.0.0.1", 8888)
        .usePlaintext(true).build();
        GreeterGrpc.GreeterBlockingStub blockingStub = GreeterGrpc.newBlockingStub(channel);
        HelloRequest request = HelloRequest.newBuilder().setName("zs").setAge(22).build();
        HelloResponse response = blockingStub.sayHello(request);
        System.out.println(response.getCode() + response.getName());
    }
    public static void shutdown() throws InterruptedException {
        channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
    }
}
